<?php
$smarty->configLoad($lang . '/events.module.php');
$language = parse_ini_file($lang . '/breadcrumb.module.php', true);
$breadcrumb = $language['events'];
$value = '';
$sql = 'SELECT * FROM '.DB_CMS.'.module_events ORDER by id DESC';
$dbh = $connection->prepare($sql);
$dbh->execute();
if(!isset($_GET['action'])) {
    $_GET['action'] = '';
}
foreach($dbh->fetchAll(PDO::FETCH_ASSOC) as $row) {
    $value[] = $row;
}

if($_GET['action'] === 'delete') {
    $main->logAction($_SESSION['id'], 'event_delete_log');
	$sql = 'DELETE FROM '.DB_CMS.'.module_events WHERE id = :id';
	$dbh = $connection->prepare($sql);
	$dbh->bindValue(':id', $_GET['id']);
	$dbh->execute();
    $main->jqmodal('events');
    echo '<meta http-equiv="refresh" content="5; URL=index.php?mod=events">';
}
$smarty->assign('value', $value);
$template = 'events/index.tpl';
?>
